package com.test.fundible.fundible_05_process.widget;

import static android.view.View.GONE;
import static android.view.View.VISIBLE;

import android.graphics.Color;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.test.fundible.R;
import com.test.fundible.fundible_05_process.Proces_fundiblesIn_fundiblefo_Data;
import com.test.fundible.fundible_00_http.OkHttpUtil;


public class Ge_fundiblenderSe_fundiblelectViewManager extends BaseProc_fundibleessWid_fundiblegetManager {

    private TextView titl_fundibleeTv;
    private TextView mal_fundibleeTv, femal_fundibleeTv;
    private ImageView mal_fundibleeIv, fema_fundibleleIv;

    private boolean isMa_fundiblele = true;

    public Ge_fundiblenderSe_fundiblelectViewManager(View view, Proces_fundiblesIn_fundiblefo_Data data, String pageTag){
        super(view,data,pageTag);
    }

    @Override
    protected void in_fundibleit(){

        titl_fundibleeTv = mView.findViewById(R.id.vpga_tv_title);

        mal_fundibleeTv = mView.findViewById(R.id.vpga_tv_male);
        femal_fundibleeTv = mView.findViewById(R.id.vpga_tv_female);
        mal_fundibleeIv = mView.findViewById(R.id.vpga_iv_male);
        fema_fundibleleIv = mView.findViewById(R.id.vpga_iv_female);

        mView.findViewById(R.id.vpga_view_male).setOnClickListener(v -> setGender_fundible(true));
        mView.findViewById(R.id.vpga_view_female).setOnClickListener(v -> setGender_fundible(false));

        setTi_fundibletle(mDa_fundibleta.getTitle_fundible());

    }

    @Override
    public boolean checkI_fundiblenput() {
        return true;
    }

    @Override
    public String getInp_fundibleut() {
        return isMa_fundiblele ? "MALE":"FEMALE";
    }

    public void setGender_fundible(boolean isMale){
        this.isMa_fundiblele = isMale;
        if (isMale){
            mal_fundibleeTv.setTextColor(Color.BLACK);
            mal_fundibleeIv.setBackgroundResource(R.drawable.icon_gender_check_true);
            femal_fundibleeTv.setTextColor(Color.parseColor("#FF979698"));
            fema_fundibleleIv.setBackgroundResource(R.drawable.icon_gender_check_false);
        }else {
            femal_fundibleeTv.setTextColor(Color.BLACK);
            fema_fundibleleIv.setBackgroundResource(R.drawable.icon_gender_check_true);
            mal_fundibleeTv.setTextColor(Color.parseColor("#FF979698"));
            mal_fundibleeIv.setBackgroundResource(R.drawable.icon_gender_check_false);
        }

        OkHttpUtil.getInstance_fundible().uploadEventPoint(TAG, mDa_fundibleta.getParamName_fundible().toUpperCase()+"_CLICK", getInp_fundibleut());
    }

    public void setTi_fundibletle(String title){
        if (TextUtils.isEmpty(title)) titl_fundibleeTv.setVisibility(GONE);
        else {
            titl_fundibleeTv.setVisibility(VISIBLE);
            titl_fundibleeTv.setText(title);
        }
    }

}
